/**
 *
 */
package com.naiterui.ehp.bs.doctor.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.naiterui.ehp.bp.domain.Department;
import com.naiterui.ehp.bs.doctor.dao.IDepartmentDao;
import com.naiterui.ehp.bs.doctor.repository.IDepartmentRepository;

/**
 * @Description 科室持久层
 */
@Component
public class AdDepartmentDaoImpl  implements IDepartmentDao {

    @Autowired
    private IDepartmentRepository departmentRepository;

    @Override
    public Department get(Integer id) {
        return departmentRepository.get(id);
    }

    @Override
    public List<Department> getDepartmentList() {
        return departmentRepository.findByAvailableOrderBySort(true);
    }

    @Override
    public List<Department> getDepartmentsByIds(List<Integer> ids) {

        return departmentRepository.findByIdInAndAvailableOrderBySort(ids, true);
    }

    @Override
    public Department getDepartmentByName(String name) {
        return departmentRepository.findFirstByNameAndParentIdNot(name, 0);
    }
}
